<div class="bg-light lter b-b wrapper-md ng-scope">
    <h4 class="m-n font-thin">身份管理</h4>
</div>
<div ng-controller="vipCtrl">
    <tabset class="tab-container wrapper">
        <tab heading="身份设置" ng-click="changeType(0)">
            <div class="panel panel-default">
                <div class="row wrapper">
                    <div class="col-sm-offset-9 col-sm-3">
                        <div class=" pull-right">
                            <a class="btn btn-sm btn-info" ui-sref="app.vipAdd" target="_blank">添加身份</a>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                </div>
                <div class="table-responsive">
                    <table class="table table-striped b-t b-light">
                        <thead>
                        <tr>
                            <th>身份标签</th>
                            <th>达成条件</th>
                            <th>获得一级分佣值(%)</th>
                            <th>获得二级分佣值(%)</th>
                            <th>获得商家加盟费占比(%)</th>
                            <th>获得商家流水占比(%)</th>
                            <th width="200">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr ng-repeat="item in list">
                            <td ng-if="item.identity == 0">
                                普通用户
                                <i class="fa fa-question-circle text-success h6" popover-placement="top"
                                   popover="权益说明：{{item.explain}}" popover-trigger="mouseenter">
                                </i>
                            </td>
                            <td ng-if="item.identity == 1">
                                VIP用户
                                <i class="fa fa-question-circle text-success h6" popover-placement="top"
                                   popover="权益说明：{{item.explain}}" popover-trigger="mouseenter">
                                </i>
                            </td>
                            <td ng-if="item.identity == 2">
                                渠道合伙人
                                <i class="fa fa-question-circle text-success h6" popover-placement="top"
                                   popover="权益说明：{{item.explain}}" popover-trigger="mouseenter">
                                </i>
                            </td>
                            <td ng-if="item.target == 0">授权登录</td>
                            <td ng-if="item.target == 1">累计消费达到{{item.value}}元</td>
                            <td ng-if="item.target == 2">一次性充值达到{{item.value}}元</td>
                            <td ng-if="item.target == 3">累计积分达到{{item.value}}分</td>
                            <td>{{item.oneSell}}</td>
                            <td>{{item.twoSell}}</td>
                            <td>{{item.joinCost}}</td>
                            <td>{{item.shopIncome}}</td>
                            <td class="t-btns">
                                <a class="btn btn-sm btn-info" ui-sref="app.vipUpdate({id:item.id})"
                                   target="_blank">修改</a>
                                <button class="btn btn-sm btn-danger" ng-click="del(item.id)">删除</button>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <div ng-if="list.length<=0 && !app.loading" class="padder-v text-center">
                        <span class="h6">~未搜索到任何数据~</span>
                    </div>
                    <div>
                        <circle-loading ng-if="app.loading"></circle-loading>
                    </div>
                </div>
                <footer class="panel-footer">
                    <div class="row">
                        <div class="col-sm-4 hidden-xs">
                        </div>
                        <div class="col-sm-4 text-center">
                            <small class="text-muted inline m-t-sm m-b-sm">显示第 {{startRow}} 至 {{endRow}} 项结果，共 {{totalItems}} 项</small>
                        </div>
                        <div class="col-sm-4 text-right text-center-xs">
                            <pagination boundary-links="true" total-items="totalItems" ng-model="page.currentPage"
                                        ng-change="replacePage()" max-size="{{maxPageRow}}" class="pagination-sm m-t-none m-b"
                                        previous-text="上一页" next-text="下一页"
                                        first-text="首页" last-text="尾页"></pagination>

                        </div>
                    </div>
                </footer>
            </div>
        </tab>
        <tab heading="变更记录" ng-click="changeType(1)">
            <div class="wrapper panel-body b-a m-b-sm padder-v">
                <div class="col-sm-9">
                    <form class="form-inline">
                        <div class="block m-t-sm">
                            <label class="control-label">变更时间</label>

                            <div class="input-group" ng-controller="DatepickerDemoCtrl">
                                <div class="input-group  no-padder m-n w-lg">
                                    <input type="text" class="input-sm form-control" placeholder="请输入开始日期"
                                           uib-datepicker-popup="yyyy-MM-dd" datepicker-popup="yyyy-MM-dd"
                                           ng-model="vipHistoryListVO.startTime"
                                           alt-input-formats="altInputFormats" is-open="opened"
                                           datepicker-options="dateOptions" close-text="关闭" clear-text="清空"
                                           current-text="今天" max-date="vipHistoryListVO.endTime"/>
                                    <span class="input-group-btn ">
                                        <button type="button" class="input-sm btn btn-default" ng-click="open($event)">
                                            <i class="glyphicon glyphicon-calendar"></i></button>
                                    </span>
                                </div>
                            </div>
                            <div class="input-group" ng-controller="DatepickerDemoCtrl">
                                <div class="input-group  no-padder m-n w-lg">
                                    <input type="text" class="input-sm form-control" placeholder="请输入结束日期"
                                           uib-datepicker-popup="yyyy-MM-dd" datepicker-popup="yyyy-MM-dd"
                                           ng-model="vipHistoryListVO.endTime"
                                           alt-input-formats="altInputFormats" is-open="opened"
                                           datepicker-options="dateOptions" close-text="关闭" clear-text="清空"
                                           current-text="今天" min-date="vipHistoryListVO.startTime" max-date="maxDate"/>
                                    <span class="input-group-btn ">
                                        <button type="button" class="input-sm btn btn-default" ng-click="open($event)">
                                            <i class="glyphicon glyphicon-calendar"></i></button>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group block m-t-sm">
                            <div class="form-group">
                                <label class="control-label">用户名</label>
                                <input type="text" ng-model="vipHistoryListVO.name" class="input-sm form-control"
                                       placeholder="请输入昵称">
                            </div>
                            <div class="form-group">
                                <label class="control-label">状态</label>
                                <select class="input-sm form-control" ng-model="vipHistoryListVO.status"
                                        ng-options="item.value as item.name for item in statusObject">
                                    <option value="">全部</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label class="control-label">身份类型</label>
                                <select class="form-control" ng-model="vipHistoryListVO.identity"
                                        ng-options="item.value as item.name for item in identityObject">
                                    <option value="">--请选择--</option>
                                </select>
                            </div>
                        </div>

                        <button class="btn btn-sm btn-info" ng-click="queryVipHistory()">查询</button>
                    </form>
                </div>
            </div>
            <div class="table-responsive">
                <table class="table table-striped b-t b-light">
                    <thead>
                    <tr>
                        <th>用户名</th>
                        <th>身份类型</th>
                        <th>手机号码</th>
                        <th>是否商户</th>
                        <th>达成条件</th>
                        <th>购买类型</th>
                        <th>支付状态</th>
                        <th>支付金额</th>
                        <th>赠送现金分</th>
                        <th>生效时间</th>
                        <th>支付方式</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="item in list">
                        <td>
                            {{item.name}}
                        </td>
                        <td>
                            <span class="label bg-light" ng-bind="{0:'普通用户',1:'VIP用户',2:'渠道合伙人'}[item.identity]"></span>
                        </td>
                        <td>
                            <span>{{item.mobilePhone}}</span>
                        </td>
                        <td>
                            <span class="badge bg-danger" ng-if="item.isShop==0">否</span>
                            <span class="badge bg-success" ng-if="item.isShop== 1">是</span>
                        </td>

                        <td>
                            <span class="label bg-light"
                                  ng-bind="{0:'授权登录',1:'累计消费',2:'充值',3:'累计积分'}[item.target]"></span>
                        </td>
                        <td>
                            <span class="label bg-light" ng-class="{0:'bg-light',1:'bg-success'}[item.purchaseType]"
                                  ng-bind="{0:'支付购买',1:'平台设置'}[item.purchaseType]"></span>
                        </td>
                        <td>
                            <span class="label bg-light"
                                  ng-class="{0:'bg-danger',1:'bg-success',2:'bg-success'}[item.status]"
                                  ng-bind="{0:'未支付',1:'已支付',2:'无需支付'}[item.status]"></span>
                        </td>
                        <td>
                            <span>{{item.payMoney | number:2}}</span>
                        </td>
                        <td>
                            <span>{{item.presentIntegral | number:2}}</span>
                        </td>
                        <td>
                            <span ng-if="item.purchaseType==0">{{item.payTime}}</span>
                            <span ng-if="item.purchaseType==1">{{item.createdTime}}</span>
                        </td>
                        <td>
                            <span class="label bg-light" ng-bind="{0:'微信支付'}[item.payWay]" ng-if="item.purchaseType==0"></span>
                            <span class="label bg-light" ng-if="item.purchaseType==1">无需支付</span>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <div ng-if="list.length<=0 && !app.loading" class="padder-v text-center">
                    <span class="h6">~未搜索到任何数据~</span>
                </div>
                <div>
                    <circle-loading ng-if="app.loading"></circle-loading>
                </div>
            </div>
            <footer class="panel-footer">
                <div class="row">
                    <div class="col-sm-4 hidden-xs">
                    </div>
                    <div class="col-sm-4 text-center">
                        <small class="text-muted inline m-t-sm m-b-sm">显示第 {{startRow}} 至 {{endRow}} 项结果，共 {{totalItems}} 项</small>
                    </div>
                    <div class="col-sm-4 text-right text-center-xs">
                        <pagination boundary-links="true" total-items="totalItems" ng-model="page.currentPage"
                                    ng-change="replacePage()" max-size="{{maxPageRow}}" class="pagination-sm m-t-none m-b"
                                    previous-text="上一页" next-text="下一页"
                                    first-text="首页" last-text="尾页"></pagination>

                    </div>
                </div>
            </footer>
        </tab>
    </tabset>
</div>
